<template>
  <div class="page">
    <el-card class="box-card">
      <!-- 标题 -->
      <div class="header">
        <el-row>
          <el-col :span="22" class="header-left">员工档案查看</el-col>
          <el-col
            v-if="props.checkStatus == 0"
            :span="2"
            class="header-right"
            @click="handleUpdate"
          >
            <el-button type="primary">编辑</el-button>
          </el-col>
        </el-row>
      </div>

      <div class="content">
        <div v-for="(item, i) in titleArr" :key="i">
          <TitleName
            :title="item"
            icon="i-carbon-bookmark-filled"
            style="margin: 10px 0 15px 0"
          ></TitleName>
          <div
            class="div-row"
            style="display: flex"
            v-for="(row, index) in fieldArr[i]"
            :key="'row' + index"
          >
            <template v-for="(col, index) in row" :key="index">
              <div class="div-item" v-if="row.length != 1">
                <span class="span-label">
                  <span class="span1">{{ col.label }}</span> :
                </span>
                <span class="span-value">
                  <span v-if="col.id == 'isTrainee'">
                    {{
                      valueObject[col.id]
                        ? valueObject[col.id] == '0'
                          ? '否'
                          : '是'
                        : '--'
                    }}
                  </span>
                  <span
                    v-else-if="col.id === 'vpn'"
                    v-hasPermi="['system:employee:authority']"
                  >
                    {{
                      valueObject[col.id]
                        ? valueObject[col.id] == '0'
                          ? '否'
                          : '是'
                        : '--'
                    }}
                  </span>
                  <span
                    v-else-if="col.id === 'classes'"
                    v-hasPermi="['system:employee:authority']"
                  >
                    {{
                      rsgl_classes.find(v => v.value == valueObject[col.id])
                        ?.label || '--'
                    }}
                  </span>
                  <span
                    v-else-if="col.id === 'jobType'"
                    v-hasPermi="['system:employee:authority']"
                  >
                    {{
                      rgsl_job_type.find(v => v.value == valueObject[col.id])
                        ?.label || '--'
                    }}
                  </span>
                  <span
                    v-else-if="col.id === 'jobTitle'"
                    v-hasPermi="['system:employee:authority']"
                  >
                    {{
                      valueObject[col.id]
                        ? valueObject[col.id]
                            .split(',')
                            .map(v => {
                              return rgsl_job_title.find(vv => vv.value == v)
                                ?.label
                            })
                            .toString()
                        : '--'
                    }}
                  </span>
                  <span
                    v-else-if="
                      col.label != '编制情况' && col.label != '业务版块'
                    "
                  >
                    {{ valueObject[col.id] ? valueObject[col.id] : '--' }}
                  </span>
                  <span
                    v-else-if="
                      col.label == '编制情况' && isEstablishment == '1'
                    "
                  >
                    {{ valueObject[col.id] ? valueObject[col.id] : '--' }}
                  </span>
                  <span v-else-if="col.label == '业务版块'">
                    <span v-if="businessSectorLeng < 19">
                      {{ valueObject[col.id] ? valueObject[col.id] : '--' }}
                    </span>
                    <el-tooltip
                      v-else
                      :content="valueObject[col.id]"
                      placement="top"
                      ><span>
                        {{ valueObject[col.id].substring(0, 19) }}...</span
                      ></el-tooltip
                    >
                  </span>

                  <span v-else> -- </span>
                </span>
              </div>
              <div class="div-item" v-else>
                <span class="span-label" style="width: 130px">
                  <span class="span1"> {{ col.label }} </span>:
                </span>
                <span class="span-value" style="flex: 1">{{
                  valueObject[col.id]
                }}</span>
              </div>
            </template>

            <div class="div-item" v-if="row.length == 2">
              <span class="span-label"></span>
              <span class="span-value"></span>
            </div>
          </div>
        </div>
      </div>
    </el-card>

    <el-card class="box-card" style="margin-top: 10px">
      <el-tabs v-model="activeName" @tab-click="handleClickNext">
        <el-tab-pane label="学习经历" name="1">
          <mytable
            :tableName="'学习经历'"
            :tableField="xxjlTableField"
            :tableData="employeeStudyList"
            @handleLink="handleLink"
          ></mytable>
        </el-tab-pane>
        <el-tab-pane label="工作经历" name="2">
          <mytable
            :tableName="'工作经历'"
            :tableField="gzjlTableField"
            :tableData="employeeWorkList"
            @handleLink="handleLink"
          ></mytable>
        </el-tab-pane>
        <el-tab-pane label="家庭关系" name="3">
          <mytable
            :tableName="'家庭关系'"
            :tableField="jtgxTableField"
            :tableData="employeeFamilyList"
          ></mytable>
        </el-tab-pane>
        <el-tab-pane label="奖惩信息" name="4">
          <mytable
            :tableName="'奖惩信息'"
            :tableField="jcxxTableField"
            :tableData="employeeRewardList"
          ></mytable>
        </el-tab-pane>
        <el-tab-pane label="合同信息" name="5">
          <mytable
            :tableName="'合同信息'"
            :tableField="htxxTableField"
            :tableData="employeeContractList"
            @handleLink="handleLink"
          ></mytable>
        </el-tab-pane>
        <el-tab-pane label="取得证书" name="6">
          <mytable
            :tableName="'取得证书'"
            :tableField="qdzsTableField"
            :tableData="employeeCertificateList"
            @handleLink="handleLink"
          ></mytable>
        </el-tab-pane>
        <!--                <el-tab-pane label="培训情况(暂略）" name="7">-->
        <!--                    <mytable :tableField="pxqkTableField"></mytable>-->
        <!--                </el-tab-pane>-->
        <el-tab-pane label="附件资料" name="8">
          <mytable
            :tableName="'附件资料'"
            :tableField="wdzlTableField"
            :tableData="employeeDocumentList"
          ></mytable>
        </el-tab-pane>
        <el-tab-pane label="社保信息" name="9">
          <div class="title" style="display: flex">
            <div class="block"></div>
            <span class="collapse-title">公司缴纳基数及比例</span>
          </div>
          <el-form label-width="100px" class="demo-ruleForm">
            <el-row
              :gutter="80"
              class="row"
              v-for="(row, index) in fieldArr[3]"
              :key="'row' + index"
            >
              <template v-for="(col, index) in row" :key="index">
                <el-col
                  class="col"
                  :span="col.col ? col.col : row.length == 1 ? 24 : 8"
                >
                  <div class="item item-label">{{ col.label }}</div>
                  <div style="display: flex; align-items: center">
                    <el-input
                      style="width: 100%"
                      class="item item-value"
                      disabled
                      v-model="valueObject[col.id]"
                    />
                  </div>
                </el-col>
              </template>
            </el-row>
          </el-form>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script setup name="DetailYage">
import { useRouter } from 'vue-router'
import mytable from './table'
import useUserStore from '@/store/modules/user'
import {
  getInfo,
  studyList,
  workList,
  familyList,
  rewardList,
  contractList,
  certificateList,
  documentList,
  getEmployeeFiles
} from '@/api/rsgl/ygda'
// import { downLoadZip } from "@/utils/zipdownload"
import { getCurrentInstance, reactive, toRefs } from 'vue'

const { proxy } = getCurrentInstance()
const route = useRouter()
const router = useRouter()
const userStore = useUserStore()
const {
  rsgl_ygda_position,
  rsgl_ygda_entrymethod,
  rsgl_ygda_registered,
  rsgl_ygda_highest_degree,
  rsgl_ygda_establishment,
  rsgl_ygda_contract,
  rsgl_ygda_employee_status,
  business_classification,
  order_business_type,
  rsgl_classes,
  rgsl_job_type,
  rgsl_job_title
} = proxy.useDict(
  'rsgl_ygda_position',
  'rsgl_ygda_entrymethod',
  'rsgl_ygda_registered',
  'rsgl_ygda_highest_degree',
  'rsgl_ygda_establishment',
  'rsgl_ygda_contract',
  'rsgl_ygda_employee_status',
  'business_classification',
  'order_business_type',
  'rsgl_classes',
  'rgsl_job_type',
  'rgsl_job_title'
)
const data = reactive({
  //业务板块字数限制
  businessSectorLeng: 0,
  // 学习经历
  employeeStudyList: [],

  // 工作经历
  employeeWorkList: [],

  // 家庭关系
  employeeFamilyList: [],

  // 奖惩信息
  employeeRewardList: [],

  // 合同信息
  employeeContractList: [],

  // 取得证书
  employeeCertificateList: [],

  // 文档资料
  employeeDocumentList: [],

  // 学习经历 表格字段
  xxjlTableField: [
    { label: '时间起', value: 'startDate' },
    { label: '时间止', value: 'endDate' },
    { label: '毕业院校', value: 'school' },
    { label: '专业', value: 'profession' },
    { label: '证书编号', value: 'certificateNo' },
    { label: '证书附件', value: 'fileName', type: 'upload' },
    { label: '学习方式', value: 'studyMethod' },
    { label: '毕业情况', value: 'graduation' }
  ],
  // 工作经历 表格字段
  gzjlTableField: [
    { label: '时间起', value: 'startDate' },
    { label: '时间止', value: 'endDate' },
    { label: '工作单位', value: 'company' },
    { label: '工作部门', value: 'dept' },
    { label: '担任职务', value: 'position' },
    { label: '证明人', value: 'certifier' },
    { label: '联系电话', value: 'tel' },
    { label: '离职原因', value: 'leaveReason' },
    { label: '证书附件', value: 'fileName', type: 'upload' }
  ],
  // 家庭关系 表格字段
  jtgxTableField: [
    { label: '序号', value: 'index' },
    { label: '关系', value: 'relation' },
    { label: '姓名', value: 'name' },
    { label: '出生年月', value: 'birthday' },
    { label: '政治面貌', value: 'political' },
    { label: '单位', value: 'company' },
    { label: '职务', value: 'position' },
    { label: '联系电话', value: 'tel' }
  ],
  // 奖惩信息 表格字段
  jcxxTableField: [
    { label: '序号', value: 'index' },
    { label: '时间', value: 'rewardDate' },
    { label: '奖惩内容', value: 'reward' },
    { label: '奖惩说明', value: 'rewardRemark' }
  ],

  // 合同信息 表格字段
  htxxTableField: [
    { label: '合同编号', value: 'contractNo' },
    { label: '签订时间', value: 'signDate' },
    { label: '合同期限', value: 'contractType', width: '160px' },
    { label: '有效期起', value: 'startDate' },
    { label: '有效期止', value: 'endDate' },
    { label: '备注', value: 'remark' },
    { label: '合同附件', value: 'fileName', type: 'upload' }
  ],
  // 取得证书 表格字段
  qdzsTableField: [
    { label: '序号', value: 'index' },
    { label: '获取时间', value: 'getDate' },
    { label: '证书名称', value: 'certificateName' },
    { label: '证书级别', value: 'certificateLevel' },
    { label: '取得证书途径', value: 'certificateAccess' },
    { label: '证书评定单位', value: 'certificateDept' },
    { label: '证书编号', value: 'certificateNo' },
    { label: '证书附件', value: 'fileName', type: 'upload' }
    // filePath
  ],
  // 培训情况 表格字段
  pxqkTableField: [
    { label: '时间起', value: 'studentCode' },
    { label: '时间止', value: 'studentName' },
    { label: '培训课程', value: 'studentAge' },
    { label: '获得证书', value: 'studentCode' },
    { label: '证书编号', value: 'studentCode' },
    { label: '备注', value: 'studentCode' }
  ],
  // 文档资料 表格字段
  wdzlTableField: [
    { label: '序号', value: 'index' },
    { label: '文档性质', value: 'documentNature' },
    { label: '附件名称', value: 'documentName', type: 'upload' }
    // filePath
  ],
  titleArr: ['基础信息', '入司情况', '教育情况'],
  activeName: '1',

  valueObject: {
    // employee基础信息
    employeeName: null,
    sex: null,
    birthday: null,
    nation: null,
    nativePlace: null,
    homeAddress: null,
    registeredType: null,
    residencePlace: null,
    currentAddress: null,
    idNumber: null,
    maritalStatus: null,
    workDate: null,
    political: null,
    entryPartyTime: null,
    technical: null,
    mobile: null,
    mail: null,
    wechat: null,
    postalCode: null,
    qq: null,
    hobbies: null,
    selfEvaluation: null,
    // employeeCompany入司情况
    companyName: null,
    deptName: null,
    position: null,
    employeeNo: null,
    job: null,
    entryMethod: null,
    entryCompanyTime: null,
    turnTime: null,
    employeeStatus: null,
    development: null,
    remark: null,
    // employeeEducation教育情况
    highestDegree: null,
    school: null,
    degreeOne: null,
    professionOne: null,
    graduationDateOne: null,
    degreeTwo: null,
    professionTwo: null,
    graduationDateTwo: null,
    // employeeSocial社保信息
    socialBase: null,
    providentBase: null,
    enterpriseBase: null,
    socialScale: null,
    providentScale: null,
    enterpriseScale: null,
    healthBase: null,
    establishment: null //编制情况
  },

  // 字段数组
  fieldArr: [
    // 基础信息
    [
      [
        { label: '姓         名', id: 'employeeName', required: true },
        {
          label: '性         别',
          id: 'sex',
          required: true,
          type: 'select',
          placeholder: '请选择性别'
        },
        { label: '出生年月', id: 'birthday', required: true, type: 'date' }
      ],
      [
        { label: '民       族', id: 'nation' },
        { label: '籍       贯', id: 'nativePlace' },
        { label: '家庭地址', id: 'homeAddress' }
      ],
      [
        {
          label: '户口性质',
          id: 'registeredType',
          type: 'select',
          placeholder: '请选择户口性质'
        },
        { label: '户籍所在地', id: 'residencePlace' },
        { label: '现住址', id: 'currentAddress' }
      ],
      [
        { label: '身份证号', id: 'idNumber' },
        {
          label: '婚姻状况',
          id: 'maritalStatus',
          type: 'select',
          placeholder: '请选择婚姻状况'
        },
        { label: '参加工作时间', id: 'workDate', type: 'date' }
      ],
      [
        {
          label: '政治面貌',
          id: 'political',
          type: 'select',
          placeholder: '请选择政治面貌'
        },
        { label: '入党/入团时间', id: 'entryPartyTime', type: 'date' },
        { label: '专业技术职称', id: 'technical' }
      ],
      [
        {
          label: '编制情况',
          id: 'establishment',
          type: 'select',
          placeholder: '请选择编制情况'
        },
        {
          label: '业务版块',
          id: 'businessSector',
          type: 'select',
          placeholder: '请选择编制情况'
        },
        { label: '手机号码', id: 'mobile' }
      ],
      [
        { label: '办公电话', id: 'officePhone' },
        { label: '个人邮箱', id: 'mail' },
        { label: '微信号码', id: 'wechat' }
      ],

      [
        { label: '邮政编码', id: 'postalCode' },
        { label: 'QQ号码', id: 'qq' },
        { label: '兴趣爱好', id: 'hobbies' }
      ],
      [
        { label: '是否vpn', id: 'vpn' },
        { label: '职类', id: 'jobType' },
        { label: '职称', id: 'jobTitle' }
      ],
      [
        { label: '分类', id: 'classes' },
        { label: '特长', id: 'speciality', placeholder: '请输入特长' },
        { label: '自我评价', id: 'selfEvaluation' }
      ]
    ],

    // 入司情况
    [
      [
        { label: '所属单位', id: 'companyName' },
        { label: '所属部门', id: 'deptName', type: 'select' },
        { label: '职务', id: 'position', type: 'select' }
      ],
      [
        { label: '员工工号', id: 'employeeNo' },
        { label: '员工编号', id: 'employeeNumber' },
        { label: '岗       位', id: 'job', type: 'select' }
      ],
      [
        { label: '岗位类别', id: 'jobCategory' },
        { label: '入职方式', id: 'entryMethod', type: 'select' },
        { label: '入司时间', id: 'entryCompanyTime' }
      ],
      [
        { label: '转正时间', id: 'turnTime' },
        { label: '员工状态', id: 'employeeStatus', type: 'select' },
        { label: '离职时间', id: 'leaveDate' }
      ],
      [
        { label: '预计转正时间', id: 'turnTimePlan' },
        { label: '职业发展设想', id: 'development', type: 'textarea' }
      ],
      [{ label: '备注', id: 'remark', type: 'textarea' }]
    ],
    // 教育情况
    [
      [
        {
          label: '最高学历',
          id: 'highestDegree',
          type: 'select',
          required: true
        },
        { label: '毕业院校 ', id: 'school', required: true },
        { label: '是否应届生', id: 'isTrainee' }
      ],
      [
        { label: '学       位', id: 'degreeOne', required: true },
        { label: '专      业', id: 'professionOne', required: true },
        {
          label: '毕业时间',
          id: 'graduationDateOne',
          type: 'date',
          required: true
        }
      ],
      [
        { label: '第二学位', id: 'degreeTwo' },
        { label: '第二专业', id: 'professionTwo' },
        { label: '毕业时间', id: 'graduationDateTwo', type: 'date' }
      ]
    ],
    // 设备信息 -- 公司缴纳基数及比例
    [
      [
        {
          label: '社保基数',
          id: 'socialBase',
          required: true,
          tip: true,
          tipContent: '请填写营业执照上完整的公司名称'
        },
        { label: '公积金基数 ', id: 'providentBase', required: true },
        { label: '企业年金 ', id: 'enterpriseBase', required: true }
      ],
      [
        { label: '社保缴纳比例(%)', id: 'socialScale' },
        { label: '公积金缴纳比例(%)', id: 'providentScale' },
        { label: '年金 比例(%)', id: 'enterpriseScale', required: true }
      ],
      [
        { label: '医保基数', id: 'healthBase', required: true, col: 8 },
        { label: '参保日期', id: 'insuredDate', type: 'date' }
      ]
    ]
  ],
  employeeIds: ''
})

const {
  // 学习经历
  employeeStudyList,
  // 工作经历
  employeeWorkList,
  // 家庭关系
  employeeFamilyList,
  // 奖惩信息
  employeeRewardList,
  // 合同信息
  employeeContractList,
  // 取得证书
  employeeCertificateList,
  // 文档资料
  employeeDocumentList,
  // 学习经历 表格字段
  xxjlTableField,
  // 工作经历 表格字段
  gzjlTableField,
  // 家庭关系 表格字段
  jtgxTableField,
  // 奖惩信息 表格字段
  jcxxTableField,

  // 合同信息 表格字段
  htxxTableField,
  // 取得证书 表格字段
  qdzsTableField,
  // 培训情况 表格字段
  pxqkTableField,
  // 文档资料 表格字段
  wdzlTableField,
  titleArr,
  activeName,

  valueObject,

  // 字段数组
  fieldArr,
  employeeIds,
  businessSectorLeng
} = toRefs(data)
const isEstablishment = ref('')
const props = defineProps({
  employeeId: {
    type: String
  },
  checkStatus: {
    type: String
  }
})

const hasAuthority = ref(false)
async function init() {
  console.log('userStore===', userStore.permissions)
  const userPermissions = userStore.permissions
  if (userPermissions.length > 0) {
    userPermissions.map(item => {
      if (item == 'system:employee:check' || item == '*:*:*') {
        isEstablishment.value = '1'
      }
      if (item == 'system:employee:authority' || item == '*:*:*') {
        hasAuthority.value = true
      }
    })
  }

  if (
    !userPermissions.includes('system:employee:authority') &&
    !userPermissions.includes('*:*:*')
  ) {
    fieldArr.value[0] = fieldArr.value[0]
      .map(v => {
        v = v.filter(item => {
          if (!['classes', 'jobType', 'jobTitle', 'vpn'].includes(item.id)) {
            return item
          }
        })
        return v
      })
      .filter(v => v.length)
    console.log(fieldArr.value[0], 'fieldArr.value[0]')
  }
  console.log('isEstablishment====', isEstablishment.value)

  if (route.currentRoute.value.query.employeeId) {
    employeeIds.value = route.currentRoute.value.query.employeeId
  } else {
    employeeIds.value = props.employeeId
  }
  let response = await getInfo(employeeIds.value)
  let data = response.data
  console.log('data==', data)
  let employee = data.employee,
    employeeCompany = data.employeeCompany,
    employeeEducation = data.employeeEducation,
    employeeSocial = data.employeeSocial
  employee.sex = employee.sex == '1' ? '男' : '女'
  employee.registeredType = rsgl_ygda_registered.value.find(
    item => item.value == employee.registeredType
  )
    ? rsgl_ygda_registered.value.find(
        item => item.value == employee.registeredType
      ).label
    : '--'
  employee.maritalStatus =
    employee.maritalStatus == '1'
      ? '已婚'
      : employee.maritalStatus == '2'
      ? '未婚'
      : '其他'
  employee.political =
    employee.political == '1'
      ? '中共党员'
      : employee.political == '2'
      ? '团员'
      : employee.political == '3'
      ? '群众'
      : '民主党派'
  employeeCompany.employeeStatus = rsgl_ygda_employee_status.value.find(
    item => item.value == employeeCompany.employeeStatus
  )
    ? rsgl_ygda_employee_status.value.find(
        item => item.value == employeeCompany.employeeStatus
      ).label
    : ''

  employeeEducation.highestDegree = rsgl_ygda_highest_degree.value.find(
    item => item.value == employeeEducation.highestDegree
  )
    ? rsgl_ygda_highest_degree.value.find(
        item => item.value == employeeEducation.highestDegree
      ).label
    : ''

  employeeEducation.establishment =
    employee.establishment == '1' ? '编制' : '非编制'
  let businessSector =
    employee.businessSector == null || employee.businessSector == ''
      ? ''
      : employee.businessSector.split(',')
  let arr = []
  let b = order_business_type.value.filter(item => {
    if (businessSector.indexOf(item.value) > -1) {
      return item
    }
  })

  b.map(item => {
    arr.push(item.label)
  })
  employee.businessSector = arr.join(',')
  businessSectorLeng.value = employee.businessSector.length

  valueObject.value = {
    ...employee,
    ...employeeEducation,
    ...employeeSocial,
    ...employeeCompany
  }

  let sendData = { employeeId: employeeIds.value }
  let studyResponse = await studyList(sendData)
  let workResponse = await workList(sendData)
  let familyResponse = await familyList(sendData)
  let rewardResponse = await rewardList(sendData)
  let contractResponse = await contractList(sendData)
  let certificateResponse = await certificateList(sendData)
  //   let documentResponse = await documentList(sendData)
  let documentResponse = await getEmployeeFiles(sendData)

  // 学习经历
  //   employeeStudyList.value = studyResponse.rows
  let array = studyResponse.rows
  if (array.length > 0) {
    const employeeStudyLists = []
    for (let i = 0; i < array.length; i++) {
      const num = array[i].fileName ? array[i].fileName.split(',').length : 0
      employeeStudyLists.push({
        ...array[i],
        fileNameNum: num
      })
    }
    employeeStudyList.value = employeeStudyLists
  } else {
    employeeStudyList.value = studyResponse.rows
  }
  console.log('学习经历', employeeStudyList.value)

  // 工作经历
  //   employeeWorkList.value = workResponse.rows
  let employeeWorkArray = workResponse.rows
  if (array.length > 0) {
    const employeeWorkListObj = []
    for (let i = 0; i < employeeWorkArray.length; i++) {
      const num = employeeWorkArray[i].fileName
        ? employeeWorkArray[i].fileName.split(',').length
        : 0
      employeeWorkListObj.push({
        ...employeeWorkArray[i],
        fileNameNum: num
      })
    }
    employeeWorkList.value = employeeWorkListObj
  } else {
    employeeWorkList.value = workResponse.rows
  }
  console.log('工作经历', employeeWorkList.value)
  // 家庭关系
  employeeFamilyList.value = familyResponse.rows
  // 奖惩信息
  employeeRewardList.value = rewardResponse.rows
  // 合同信息
  //   employeeContractList.value = contractResponse.rows
  let employeeContractArray = contractResponse.rows
  employeeContractArray.map(item => {
    item.contractType = rsgl_ygda_contract.value.find(
      a => a.value == item.contractType
    )
      ? rsgl_ygda_contract.value.find(a => a.value == item.contractType).label
      : ''
  })
  console.log('rsgl_ygda_contract===合同', employeeContractArray)
  if (array.length > 0) {
    const employeeContractObj = []
    for (let i = 0; i < employeeContractArray.length; i++) {
      const num = employeeContractArray[i].fileName
        ? employeeContractArray[i].fileName.split(',').length
        : 0
      employeeContractObj.push({
        ...employeeContractArray[i],
        fileNameNum: num
      })
    }
    employeeContractList.value = employeeContractObj
  } else {
    employeeContractList.value = contractResponse.rows
  }
  console.log('合同信息', employeeContractList.value)

  // 取得证书
  //   employeeCertificateList.value = certificateResponse.rows
  let employeeCertificateArray = certificateResponse.rows
  if (array.length > 0) {
    const employeeCertificateObj = []
    for (let i = 0; i < employeeCertificateArray.length; i++) {
      const num = employeeCertificateArray[i].fileName
        ? employeeCertificateArray[i].fileName.split(',').length
        : 0
      employeeCertificateObj.push({
        ...employeeCertificateArray[i],
        fileNameNum: num
      })
    }
    employeeCertificateList.value = employeeCertificateObj
  } else {
    employeeCertificateList.value = certificateResponse.rows
  }
  console.log('取得证书', employeeCertificateList.value)
  // 文档资料
  employeeDocumentList.value = documentResponse.rows
}
init()
//跳转
function handleLink(employeeId, id, tableName, index, item) {
  activeName.value = item
  let source = ''
  console.log('handleLink===2', id, tableName, index, item)
  console.log('tableName', tableName)
  if (tableName == '学习经历') {
    source = 'tb_employee_study'
  } else if (tableName == '合同信息') {
    source = 'tb_employee_contract'
  } else if (tableName == '取得证书') {
    source = 'tb_employee_certificate'
  } else if (tableName == '工作经历') {
    source = 'tb_employee_work'
  }
  getEmployeeFiles({
    employeeId: employeeId,
    documentNature: source,
    documentNo: id
  }).then(res => {
    let documentResponse = res.rows
    employeeDocumentList.value = documentResponse
    // employeeDocumentList.value = res.data
    // window.location.href = res.config.url
  })
}
//tab切换
async function handleClickNext(tab, event) {
  console.log('activeName', tab.paneName)
  if (tab.paneName == '8') {
    let sendData = { employeeId: employeeIds.value }
    let documentResponse = await getEmployeeFiles(sendData)
    // 文档资料
    employeeDocumentList.value = documentResponse.rows
  }
}

/** 编辑操作 */
function handleUpdate() {
  router.push({
    path: '/rsgl/rs/editYgda',
    query: { flag: 'update', employeeId: employeeIds.value }
  })
}
</script>

<style scoped lang="scss">
.page {
  padding: 20px;
  .box-card {
    border-radius: 10px;
  }
}
.el-descriptions {
  margin-top: -1px;
}
.cell-item {
  display: flex;
  align-items: center;
}

.el-collapse {
  margin-bottom: 40px;
}

.header {
  align-items: center;
  vertical-align: middle;
  //   margin-bottom: 20px;
  margin-top: 10px;
  margin-right: 12px;
  .header-left {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    // width: 100%;
  }
  .header-right {
    width: 120px;
    line-height: 30px;
    text-align: right;
    color: #1890ff;
    cursor: pointer;
  }
}
.content {
  padding: 10px;
}
.collapse-title {
  font-weight: 600;
  font-size: 15px;
}

.block {
  width: 5px;
  display: inline-block;
  height: 16px;
  background-color: rgb(62, 146, 255);
  margin-right: 8px;
}

.title {
  display: flex;
  align-items: center;
  margin-top: 20px;
  margin-bottom: 15px;
}

.collapse .row:last-child {
  margin-bottom: 10px;
}

.item-label,
.item-value {
  text-align: center;
  font-size: 12px;
  line-height: 30px;
}

.item-label {
  text-align: left;
}

.footer {
  background-color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60px;
  border-top: 1px solid lightgray;
  z-index: 99999;

  .el-button {
    width: 100px;
  }
}
.div-row {
  // display: flex;
  width: 100%;
  .div-top {
    border-top: 1px solid #eee;
    width: 100%;
  }
  .div-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-size: 14px;
    .span-label {
      align-items: center;
      display: flex;
      justify-content: end;
      height: 45px;
      color: #777;
      font-weight: bolder;
      background-color: #f5f7fa;
      //   border-left: 1px solid #eee;
      width: 130px;
      font-size: 14px;
      padding-right: 10px;
      border: 1px solid #eee;

      .span1 {
        text-align: justify;
        align-items: center;
        min-width: 75px;
        padding: 12px 5px 7px 12px;
        line-height: 24px;
        height: 45px;
        text-align-last: justify;
      }
      .span1:after {
        content: '';
        display: inline-block;
        width: 100%;
      }
    }

    .span-value {
      align-items: center;
      display: flex;
      flex: 1;
      padding-left: 10px;
      height: 45px;
      border-right: 1px solid #eee;
      border-bottom: 1px solid #eee;
      border-top: 1px solid #eee;
      color: #000;
      //   margin-top: -1px;
    }
  }
}

::v-deep .el-input.is-disabled .el-input__inner {
  color: #121213 !important;
}
</style>
